package com.edu.ad.controller;

import com.edu.ad.service.PromotionSpaceService;
import com.edu.api.entity.ad.PromotionSpace;
import com.edu.api.entity.common.Pageable;
import com.edu.api.entity.common.ResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;

/**
 * @description: 描述
 * @author: xnylh
 * @createDate: 2023/1/23 0023 21:11
 */
@RestController
@RequestMapping("promotionSpace")
public class PromotionSpaceController {

    @Autowired
    PromotionSpaceService spaceService;

    @PostMapping("/addOrUpdateBackStageSpace")
    public ResponseDTO addOrUpdateBackStageSpace(@RequestBody PromotionSpace space, HttpServletRequest request){
        return spaceService.addOrUpdateBackStageSpace(space,request);
    }

    @GetMapping("/getAllSpace")
    public ResponseDTO getAllSpace(Integer page, Integer size, PromotionSpace space) throws ParseException {
        Pageable pageable = new Pageable();
        pageable.setPage(page);
        pageable.setSize(size);
        return spaceService.getAllSpace(pageable,space);
    }


    @DeleteMapping("/deleteBackstageSpace")
    public ResponseDTO deleteSpace(@RequestBody List<Integer> ids){
        return spaceService.deleteSpaceByIds(ids);
    }
}
